<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8"/>
    <title>档号格式设置</title>
    <meta name="renderer" content="webkit"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
    <meta
            name="viewport"
            content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0"
    />
    <link rel="stylesheet" href="../js/layui/css/layui.css" media="all"/>
    <link rel="stylesheet" href="../style/admin.css" media="all"/>
    <link rel="stylesheet" href="../style/home.css" media="all"/>
    <script src="../js/layui/layui.js"></script>
    <style>
        .layui-form-item .layui-inline {
            padding-right: 0px;
            margin-right: 0px;
        }

        body {
            background-color: #fff;
            width: 100%;
            height: 100%;
            margin: 0px;
            padding: 0px;
            border: 0px;
        }

        .layui-form-select dl {
            max-height: 120px;
        }
    </style>
</head>
<body layadmin-themealias="default">
<div class="" style="padding: 20px">
    <div class="layui-row layui-col-space15">
        <div class="layui-card pr20" style="height: 180px">
            <form class="layui-form" lay-filter="postData" action="" id="postData">
                <input type="hidden" name="id" value="put" th:value="${data.id}"/>
                <input type="hidden" name="pid" value="put" th:value="${data.pid}"/>
                <input type="hidden" name="classifyId" value="put" th:value="${data.classifyId}"/>
                <input type="hidden" name="codeModel" value="put" th:value="${data.codeModel}"/>
                <input type="hidden" name="children" value="put" th:value="${data.children}"/>
                <input type="hidden" name="parentId" value="put" th:value="${data.parentId}"/>
                <div class="layui-form-item">
                    <label class="layui-form-label">字段</label>
                    <div class="layui-input-block">
                        <select name="fieldName" id="fieldName" lay-filter="fieldName" lay-search="" required
                                lay-verify="required">
                            <option value="">直接选择或搜索选择</option>
                            <option th:selected="${option.fieldName eq data.fieldName}"
                                    th:each="option : ${fieldList}"
                                    th:value="${option.fieldName}" th:text="${option.fieldTitle}"></option>
                        </select>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">连接符</label>
                    <div class="layui-input-block">
                        <input type="text" name="doc" placeholder="请输入连接符" autocomplete="off" class="layui-input"
                               th:value="${data.doc}">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">长度</label>
                    <div class="layui-input-block">
                        <input type="text" name="len" required lay-verify="number" placeholder="请输入长度"
                               autocomplete="off" class="layui-input" th:value="${data.len}">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">排序</label>
                    <div class="layui-input-block">
                        <input type="text" name="idx" required lay-verify="number" placeholder="请输入顺序号"
                               autocomplete="off" class="layui-input" th:value="${data.idx}">
                    </div>
                </div>
                <button type="submit" class="layui-btn" lay-submit="" lay-filter="postData" id="postBut"
                        style="display: none">
                    立即提交
                </button>
            </form>
        </div>
    </div>
</div>
<script>
    var form = layui.form;
    var $ = layui.$;
    var callBackReturn = false,
        tree = layui.tree,
        OnPost = false;
    var index = parent.layer.getFrameIndex(window.name);
    classifyId = "[[${classifyId}]]";
    pid = "[[${pid}]]";
    codeModel = "[[${codeModel}]]";
    children = "[[${children}]]";
    parentId = "[[${parentId}]]";
    fillingModel = "[[${fillingModel}]]";
    form.render(null, 'postData');


    form.on('submit(postData)', function (obj) {
        var data = obj.field;
        data["title"] = $("#fieldName").find("option:selected").text();
        $.ajax({
            url: './saveArchivesCodeFormat', //url
            contentType: 'application/json',
            dataType: 'json', //数据格式
            type: 'POST', //请求方式
            async: false, //是否异步请求
            data: JSON.stringify(data),
            success: function (result) {
                if (result.code == 0) {
                    parent.layer.msg(result.message, {icon: 1});
                    callBackReturn = true;
                    OnPost = true;
                    parent.layer.close(index);
                } else {
                    OnPost = true;
                    parent.layer.alert(result.message, {icon: 2});
                }
            },
        });
        return false;
    });

    function Buttun_Submit() {
        document.getElementById('postBut').click();
        return callBackReturn;
    }
</script>
<script type="text/javascript" src="../js/lib/watermark.js"></script>
</body>
</html>